home *** CD-ROM | disk | FTP | other *** search
/ Dream 55 / Amiga_Dream_55.iso / RISCOS / APPS / TEXT / PS / KIT-PS.ZIP / Kit PS / !PSUtils / !RunImage (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1997-02-20  |  58KB  |  2,275 lines

  1.  !PsUsils - Front end to psutils package.
  2.  Frontend (C) Graham Jones, 1995
  3.  Psutils package (C) Angus Duggan
  4. memory(
  5.    Next initialise the application with the WIMP, giving the task name,
  6.    sprite name and selecting buffer size of 1024.
  7. font_init
  8. grj_wimp_init("PSUtils Frontend","!psutils",
  9. ,2048,200,0)
  10.    Set up out error trap :
  11. grj_update_bartext( "Psnup" )
  12. wimp_error(1,
  13. $+" at line "+
  14. wimp_quit
  15.  Setup various variables
  16.  CL$(6): 
  17.  6 command lines
  18.  wins%(6), psize%(6,2), custom_page%(6,2,2): 
  19.  pane% 2048
  20.  pages%(20,5)
  21. pagespecs% = 
  22. malloc(24)
  23. psnupwin%=0
  24. pstopswin%=1
  25. psbookwin%=2
  26. epsffitwin%=3
  27. psresizewin%=4
  28. psselectwin%=5
  29. config_name$ = ""
  30. config_on_save% = 
  31. curr_selection% = psnupwin%
  32. infile$ = ""
  33. psize%(psnupwin%,0) = 1
  34. psize%(psnupwin%,1) = 1
  35. psize%(pstopswin%,0) = 1
  36. psize%(psresizewin%,0) = 1
  37. psize%(psresizewin%,1) = 1
  38. size_win% = -1
  39. nup_win% = -1
  40. big_page_open% = 
  41. pw% = 0: ph% = 0: sc = 1.0
  42. mag% = 1: div% = 1
  43. flags_off% = 4
  44. scale_off% = 5
  45. xoff_off% = 10
  46. yoff_off% = 15
  47. fl%    = %00000001
  48. fr%    = %00000010
  49. fu%    = %00000100
  50. fsc%   = %00001000
  51. fplus% = %00010000
  52. fend%  = %00100000
  53. foff%  = %01000000
  54.  I%=0 
  55.  J% = 0 
  56. A#    custom_page%(I%, J%, 0)=595
  57. B#    custom_page%(I%, J%, 1)=842
  58.    Next initialise the templates routines. This takes no parameters.
  59. win_init(10)
  60.  PROCfont_init
  61. JHtrin% = 
  62. font_gethandle("Trinity.Medium", 12, 12) : 
  63.  Lets try this 
  64. temp_init
  65. transfer_init
  66. create_windows
  67. setup_menus
  68. setup_windows
  69. mid_save% = 
  70. saving%=
  71. drag_action% = 1
  72. psnup_CL
  73. pstops_CL
  74. epsffit_CL
  75. psbook_CL
  76. psresize_CL
  77. psselect_CL
  78. wimp_poll(0,0,0)
  79.  Never reached but it doesn't feel right not being there!
  80. wimp_mainmenu
  81. create_windows
  82.    Now we can read the application's templates file :
  83. temp_readfile("<PSUtils$Dir>.Templates",2600)
  84. n$  info% = 
  85. win_createwin("Info")
  86. oB  psnup% = 
  87. win_createwin("PSNup") : wins%(psnupwin%) = psnup%
  88. pF  pstops% = 
  89. win_createwin("PsToPs") : wins%(pstopswin%) = pstops%
  90. qJ  epsffit% = 
  91. win_createwin("EpsfFit") : wins%(epsffitwin%) = epsffit%
  92. rF  psbook% = 
  93. win_createwin("PsBook") : wins%(psbookwin%) = psbook%
  94. sN  psresize% = 
  95. win_createwin("PsResize") : wins%(psresizewin%) = psresize%
  96. tN  psselect% = 
  97. win_createwin("PsSelect") : wins%(psselectwin%) = psselect%
  98. u)  savewin% = 
  99. win_createwin("SaveAs")
  100. v,  topspane% = 
  101. win_createwin("toPsPane")
  102. w0  pstopsedit% = 
  103. win_createwin("PstoPsEdit")
  104. get_pagesize(pstopswin%, 0, 5, pw%, ph%)
  105. z7  sc = 216/pw%: sc1 = 184/ph%: 
  106. (sc1 < sc) sc = sc1
  107.   pw% = pw% * sc: ph% = ph% * sc
  108. win_resize(topspane%, pw%*sc, ph%*sc)
  109. win_closewin(topspane%)
  110. setup_psnup
  111. icon_shade(psnup%,5)
  112. icon_shade(psnup%,6)
  113. icon_settext(psnup%, 25, "A4")
  114. icon_shade(psnup%,3)
  115. icon_shade(psnup%,4)
  116. icon_settext(psnup%, 26, "A4")
  117. icon_shade(psnup%,8)
  118. icon_shade(psnup%,9)
  119. icon_shade(psnup%,10)
  120. icon_shade(psnup%,11)
  121. get_pagesize( psnupwin%, 0, 5, X%, Y% )
  122. icon_settext(wins%(psnupwin%), 5, 
  123. (X%))
  124. icon_settext(wins%(psnupwin%), 6, 
  125. (Y%))
  126. get_pagesize( psnupwin%, 1, 3, X%, Y% )
  127. icon_settext(wins%(psnupwin%), 3, 
  128. (X%))
  129. icon_settext(wins%(psnupwin%), 4, 
  130. (Y%))
  131. setup_pstops
  132. icon_shade(pstops%,5)
  133. icon_shade(pstops%,6)
  134. icon_settext(pstops%, 3, "A4")
  135. icon_shade(pstops%,10)
  136. get_pagesize( pstopswin%, 0, 5, X%, Y% )
  137. icon_settext(wins%(pstopswin%), 5, 
  138. (X%))
  139. icon_settext(wins%(pstopswin%), 6, 
  140. (Y%))
  141. setup_epsffit
  142. setup_psbook
  143. setup_psresize
  144. icon_shade(psresize%,5)
  145. icon_shade(psresize%,6)
  146. icon_settext(psresize%, 3, "A4")
  147. get_pagesize( psresizewin%, 0, 5, X%, Y% )
  148. icon_settext(wins%(psresizewin%), 5, 
  149. (X%))
  150. icon_settext(wins%(psresizewin%), 6, 
  151. (Y%))
  152. icon_shade(psresize%,13)
  153. icon_shade(psresize%,14)
  154. icon_settext(psresize%, 10, "A4")
  155. get_pagesize( psresizewin%, 1, 13, X%, Y% )
  156. icon_settext(wins%(psresizewin%), 13, 
  157. (X%))
  158. icon_settext(wins%(psresizewin%), 14, 
  159. (Y%))
  160. setup_psselect
  161. setup_windows
  162. setup_psnup
  163. setup_pstops
  164. setup_epsffit
  165. setup_psbook
  166. setup_psresize
  167. setup_psselect
  168. setup_menus
  169.  this_name$, i%
  170.    Next initialise the menu library, stating that we intend to have
  171.    2 menus (we can change this value later if more are needed).
  172. menu_init(3)
  173.    Create the first (number 0) menu, giving it a title of "Test App" and
  174.    giving it 3 entries :
  175. menu_header("PsUtils",0,8)
  176. menu_header("",1,1)
  177. menu_header("Page sizes",2,14)
  178.    Now create the 3 entries, one being "Info", the second "Sub Menu"
  179.    and the third "Quit".
  180. menu_additem(0,0,"Info",menu_dotted)
  181. menu_additem(0,2,"Ps to Ps",0)
  182. menu_additem(0,1,"Ps Nup",menu_tick)
  183. menu_additem(0,3,"Ps Book",0)
  184. menu_additem(0,4,"Epsf Fit",0)
  185. menu_additem(0,5,"Ps Resize",0)
  186. menu_additem(0,6,"Ps Select",menu_dotted)
  187. menu_additem(0,7,"Quit",0)
  188. menu_additem(1,0,"Configure",0)
  189.  i% = 1 
  190. menu_submenu(0,i%,1)
  191. menu_subwindow(0,0,info%)
  192. menu_additem(2,0,"Custom",menu_dotted)
  193.  i% = 1 
  194. #    this_name$ = 
  195. page_name(i%)
  196. @    this_name$ = 
  197. toupper(
  198. this_name$, 1)) + 
  199. this_name$, 2)
  200. (    
  201. menu_additem(2,i%,this_name$,0)
  202. event_menuselection(B%)
  203.    Find out what entry in the first menu was selected
  204.  _wimp_oldmenu%=0 
  205.  !B% 
  206.       
  207. 2             curr_selection% = curr_selection%
  208. A      
  209.  7:                       
  210.    Sub menu, follow it down
  211.              
  212. wimp_quit
  213.       
  214. #        
  215. pstops_menu(!B%, B%!4)
  216.         
  217. ,    
  218.  _wimp_oldmenu% = 2 
  219. page_menu(!B%)
  220. page_menu(sel%)
  221.  X%,Y%
  222.   new_nup% = sel%
  223.   resize_in% = 0
  224.   to_shade% = 5
  225.   show_size% = 3
  226.   real_win% = size_win%
  227.  ((size_win% < 0) 
  228.  (real_win% = -psresize%)) 
  229.     real_win% = -size_win%
  230.     resize_in% = 1
  231.     to_shade% = 13
  232.     show_size% = 10
  233. 5    
  234.  ((size_win% < 0) 
  235.  (real_win% = -psnup%)) 
  236.        real_win% = -size_win%
  237.       resize_in% = 1
  238.       to_shade% = 3
  239.       show_size% = 25
  240.         
  241.        
  242.  (real_win% = psnup%)
  243.         show_size% = 26
  244.       
  245.         
  246. *  this_win% = 
  247. which_winnum(real_win%)
  248. menu_untick(2, psize%(this_win%,resize_in%))
  249. -  psize%(this_win%,resize_in%) = new_nup%
  250. menu_tick(2, psize%(this_win%,resize_in%))
  251.  psize%(this_win%,resize_in%)=0 
  252. ,    
  253.  Un-grey out the width/height boxes
  254. 1    
  255. icon_unshade(wins%(this_win%),to_shade%)
  256. 3    
  257. icon_unshade(wins%(this_win%),to_shade%+1)
  258.  /    
  259. icon_shade(wins%(this_win%),to_shade%)
  260. !1    
  261. icon_shade(wins%(this_win%),to_shade%+1)
  262.  psize%(this_win%,resize_in%) = 0 
  263. %3    X% = custom_page%(this_win%, resize_in%, 0)
  264. &3    Y% = custom_page%(this_win%, resize_in%, 1)
  265. '=    
  266. icon_settext(wins%(this_win%), show_size%, "Custom")
  267. (9    
  268. icon_settext(wins%(this_win%), to_shade%, 
  269. (X%))
  270. );    
  271. icon_settext(wins%(this_win%), to_shade%+1, 
  272. (Y%))
  273. +=    this_name$ = 
  274. page_name(psize%(this_win%,resize_in%))
  275. ,A    this_name$ = 
  276. toupper(
  277. this_name$, 1)) + 
  278. this_name$, 2) 
  279. -?    
  280. icon_settext(wins%(this_win%), show_size%, this_name$)
  281. .A    
  282.  Get the page size and put it into the appropriate icons
  283. /A    
  284. get_pagesize( this_win%, resize_in%, to_shade%, X%, Y% )
  285. 09    
  286. icon_settext(wins%(this_win%), to_shade%, 
  287. (X%))
  288. 1;    
  289. icon_settext(wins%(this_win%), to_shade%+1, 
  290. (Y%))
  291. pstops_menu(sel%, sub%)
  292.  X%,Y%,x%,y%
  293.  There is only one menu item on the submenu and it must have been clicked.
  294.  (sub% = -1) 
  295. ;*    
  296. menu_untick(0, curr_selection%+1)
  297. <$    curr_selection% = (sel%) - 1
  298. =(    
  299. menu_tick(0, curr_selection%+1)
  300.  curr_selection% 
  301.       
  302.  psnupwin%:
  303. @(        
  304. grj_update_bartext("PsNup")
  305.       
  306.  pstopswin%:
  307. B)        
  308. grj_update_bartext("PsToPs")
  309.       
  310.  epsffitwin%:
  311. D*        
  312. grj_update_bartext("EpsfFit")
  313.       
  314.  psresizewin%:
  315. F+        
  316. grj_update_bartext("PsResize")
  317.       
  318.  psbookwin%:
  319. H)        
  320. grj_update_bartext("PsBook")
  321.       
  322.  psselectwin%:
  323. J+        
  324. grj_update_bartext("PsSelect")
  325. K        
  326.     which% = sel%-1
  327. N;    
  328.  (big_page_open%) 
  329.  (which% = wins%(pstopswin%)) 
  330. O)    
  331. win_getsize(wins%(which%),x%,y%)
  332. os_screensize(X%,Y%)
  333. Q9    
  334. win_movewin(wins%(which%),(X%-x%)
  335.  2,(Y%-y%)
  336. R&    !B%=
  337. win_handle(wins%(which%))
  338.  &400CB,,B%
  339.     B%!28 = -1
  340.  &400C5,,B%
  341. call_setup(which%)
  342. call_setup(num%)
  343.  num% 
  344.  psnupwin%:
  345.       
  346. psnup_setup
  347.  pstopswin%:
  348.       
  349. pstops_setup
  350.  epsffitwin%:
  351.       
  352. epsffit_setup
  353.  psbookwin%:
  354.       
  355. psbook_setup
  356.  psresizewin%:
  357.       
  358. psresize_setup
  359.  psselectwin%:
  360.       
  361. psselect_setup
  362. call_CL(num%)
  363.  num% 
  364.  psnup%:
  365.       
  366. psnup_CL
  367.  pstops%:
  368.       
  369. pstops_CL
  370.  epsffit%:
  371.       
  372. epsffit_CL
  373.  psbook%:
  374.       
  375. psbook_CL
  376.  psresize%:
  377.       
  378. psresize_CL
  379.  psselect%:
  380.       
  381. psselect_CL
  382. event_iconbaradjust(B%)
  383. }4  new_selection% = ((curr_selection%+1) 
  384.  6) + 1
  385. pstops_menu( new_selection%, -1 )  
  386. event_iconbarselect(B%)
  387.  X%,Y%,x%,y%,xmin%,ymin%,xmax%,ymax%
  388.  saving% = 
  389. =    
  390.  (big_page_open%) 
  391.  (curr_selection% = pstopswin%) 
  392. 2    
  393. win_getsize(wins%(curr_selection%),x%,y%)
  394. os_screensize(X%,Y%)
  395. F    
  396. win_getextent(wins%(curr_selection%),xmin%,ymin%,xmax%,ymax%)
  397. B    
  398. win_movewin(wins%(curr_selection%),(X%-x%)
  399.  2,(Y%-y%)
  400. /    !B%=
  401. win_handle(wins%(curr_selection%))
  402.  &400CB,,B%
  403.     B%!28 = -1
  404.  &400C5,,B%
  405. $    
  406. call_setup(curr_selection%)
  407. transfer_willload(type%, open%)
  408. (    
  409.  (type% = &FF5) 
  410.  (open% = 
  411. 0     
  412.  if it's PostScript and not a dataopen
  413.        =
  414.         
  415.        =
  416.         
  417.     ENDFN
  418. transfer_loadfile(name$, type%, is_safe%)
  419.  x%,y%,z%,w%,h%
  420.   infile$ = name$
  421. icon_settext(savewin%, 2, infile$)
  422.  Do a save drag to get an output filename, then get all the PSNup options set and call
  423.  the program
  424.  x%,y%,z%
  425. win_getsize(savewin%,w%,h%)          :   
  426.  Get window size into x%,y%
  427. win_movewin(savewin%,x%, y%)
  428. icon_setcaret(savewin%, 2, -1)
  429.   saving% = 
  430. savewin_click(icon%, but%)
  431.  Just got a mouse click, now check for a drag with it.
  432.  (icon%=0) 
  433.  ((but% = 16) 
  434.  (but% = 64)) 
  435. N    
  436. transfer_startdrag(
  437. icon_gettext(savewin%, 2), &FF5, 10, savewin%, 0)
  438.         
  439.  icon%=1 
  440. ,    
  441.  Check the file has a path with it.
  442. -    outfile$ = 
  443. icon_gettext(savewin%, 2)
  444. outfile$, ".") = 0 
  445. h      hello%=
  446. wimp_messagebox(
  447. , "Warning from PSUtils","Drag the file icon to a directory to save")
  448.       
  449.         
  450. &    
  451.  if it has then save the file
  452. >    
  453.  otherwise pop up a warning window and tell the user.
  454. -    
  455. transfer_savefile(outfile$, &FF5, 0)
  456. (    
  457.  but%=4 
  458. win_closewin(savewin%)
  459.         
  460. click_ok(win%, but%)
  461.  which_win%
  462.  Any of the config windows.
  463. %  which_win% = 
  464. win_findwin(win%)
  465. call_CL(which_win%)
  466. (which_win% = pstops%) 
  467. (but% = 1) 
  468. 0      
  469. win_resize(topspane%, pw%*sc, ph%*sc)
  470. '      !pane% = 
  471. win_handle(pstops%)
  472. *      
  473.  "Wimp_GetWindowState",, pane%
  474. 1      
  475.  "Wimp_SendMessage", 2, pane%, !pane%
  476. #      
  477. win_redrawwin(topspane%)
  478.         
  479.  mid_save% 
  480. 9    
  481. which_winnum(which_win%) = curr_selection%) 
  482.       mid_save% = 
  483. 3      
  484. transfer_savefile(config_name$, &FF5, 0)
  485. 0      
  486.  Call the PROC to save the file .....
  487.         
  488.  (but% = 4) 
  489. !    
  490. win_closewin(which_win%)
  491. 8    
  492. (which_win% = pstops%) 
  493. win_closewin(topspane%)
  494. page_click(win%, but%, icon%)
  495.  but% <> 0 
  496.  x%,y%,z%
  497.     resize% = 
  498.     nup% = 
  499. ;    
  500. win_findwin(win%) = psresize%) 
  501.  (icon%=15)) 
  502.       resize% = 
  503. (      new_win% = -
  504. win_findwin(win%)
  505.       new_real% = -new_win%
  506.       new_resize% = 1
  507.         
  508. :      
  509. win_findwin(win%) = psnup%) 
  510.  (icon%=29)) 
  511.         resize% = 
  512. *        new_win% = -
  513. win_findwin(win%)
  514. !        new_real% = -new_win%
  515.         new_resize% = 1
  516.       
  517. )        new_win% = 
  518. win_findwin(win%)
  519.          new_real% = new_win%
  520.         new_resize% = 0
  521.       
  522.         
  523.     resize_in% = 0
  524.     real_win% = size_win%
  525. (size_win% < -1) 
  526.        real_win% = -size_win%
  527.       resize_in% = 1
  528.         
  529. W    
  530. (real_win% <> -1) 
  531. menu_untick(2, psize%(
  532. which_winnum(real_win%),resize_in%))
  533.     size_win% = new_win%
  534.     real_win% = new_real%
  535. C    
  536. menu_tick(2, psize%(
  537. which_winnum(real_win%),new_resize%))
  538. menu_popup(2, x%,y%)
  539. psnup_click(B%)
  540.  (B%!16=12) 
  541.  (B%!16=29) 
  542. %    
  543. page_click(B%!12,B%!8,B%!16)
  544.     icon% = B%!16
  545. M    
  546.  Put any other checks before this section 'cos it doesn't check icon
  547. 3    
  548.  number before getting in there and acting
  549. .    
  550. icon_getselect( psnup%, icon% )) 
  551. 0      
  552.  (icon%=13) 
  553. icon_unshade( psnup%,8 )
  554. .      
  555.  (icon%=14) 
  556. icon_unshade(psnup%,9)
  557.     /      
  558.  (icon%=19) 
  559. icon_unshade(psnup%,10)
  560. /      
  561.  (icon%=20) 
  562. icon_unshade(psnup%,11)
  563.         
  564. ,      
  565.  (icon%=13) 
  566. icon_shade(psnup%,8)
  567. ,      
  568.  (icon%=14) 
  569. icon_shade(psnup%,9)
  570. -      
  571.  (icon%=19) 
  572. icon_shade(psnup%,10)
  573. -      
  574.  (icon%=20) 
  575. icon_shade(psnup%,11)
  576.         
  577. pstops_click(B%)
  578.  (B%!16=12) 
  579. %    
  580. page_click(B%!12,B%!8,B%!16)
  581.     icon% = B%!16
  582. M    
  583.  Put any other checks before this section 'cos it doesn't check icon
  584. 3    
  585.  number before getting in there and acting
  586. /    
  587. icon_getselect( pstops%, icon% )) 
  588. 2      
  589.  (icon%=11) 
  590. icon_unshade( pstops%,10 )
  591.         
  592. 0      
  593.  (icon%=11) 
  594. icon_shade( pstops%,10 )
  595.         
  596. epsffit_click(B%)
  597. psbook_click(B%)
  598. psresize_click(B%)
  599.  (B%!16=12) 
  600.  (B%!16=15) 
  601. +%    
  602. page_click(B%!12,B%!8,B%!16)
  603. psselect_click(B%)
  604. event_mouseclick(B%)
  605.  B%!12=
  606. win_handle(savewin%) 
  607. savewin_click(B%!16, B%!8): 
  608.    IF (FNwin_findwin(B%!12) = topspane%) PROCopen_bigpage: ENDPROC
  609.  B%!16=1 
  610. click_ok(B%!12, B%!8): 
  611. win_findwin(B%!12) 
  612.  psnup%:
  613.       
  614. psnup_click(B%)
  615.  pstops%:
  616.       
  617. pstops_click(B%)
  618.  epsffit%:
  619.       
  620. epsffit_click(B%)
  621.  psbook%:
  622.       
  623. psbook_click(B%)
  624.  psresize%:
  625.       
  626. psresize_click(B%)
  627.  psselect%:
  628.       
  629. psselect_click(B%)
  630.  topspane%:
  631.       
  632. open_bigpage
  633.     WHEN pstopsedit%:
  634.        PROCbigpage_click(B%)
  635. open_bigpage
  636.  x%, y%, X%, Y%
  637.   big_page_open% = 
  638. win_closewin(pstops%): 
  639. win_closewin(topspane%)
  640. get_pagesize(pstopswin%, 0, 5, x%, y%)
  641. win_setextent(pstopsedit%, 0, -y%*mag%/div%, x%*mag%/div%, 0)
  642. win_resize(pstopsedit%, x%*mag%/div%, y%*mag%/div%)
  643. os_screensize(X%,Y%)
  644. win_movewin(pstopsedit%,(X%-x%)
  645.  2,(Y%-y%)
  646. transfer_savefile(name$, type%, safe%)
  647.  saving%=
  648. win_closewin(savewin%)
  649.   saving%=
  650.  config_on_save% 
  651. [2    
  652. win_getsize(wins%(curr_selection%),x%,y%)
  653. os_screensize(X%,Y%)
  654. ]B    
  655. win_movewin(wins%(curr_selection%),(X%-x%)
  656.  2,(Y%-y%)
  657. ^$    
  658. call_setup(curr_selection%)
  659.     config_name$ = name$
  660.     mid_save% = 
  661. a        
  662.  hello% = FNwimp_messagebox(FALSE, "Command line", CL$(curr_selection%)+" "+infile$+" "+name$)
  663.  "Wimp_StartTask",CL$(curr_selection%)+" "+infile$+" "+name$
  664.  "OS_File",18,name$,&FF5
  665. psnup_CL
  666.  the selections
  667.  lscape$, seascape$, swap$, cols$, sheet$, page$, border$, scale$
  668.  outsize$, pages$, insize$
  669.  Get the variables to the command line
  670. icon_getselect(psnup%, 15) lscape$ = " -l" 
  671.  lscape$=""
  672. icon_getselect(psnup%, 16) seascape$ = " -r" 
  673.  seascape$=""
  674. icon_getselect(psnup%, 17) swap$ = " -f" 
  675.  swap$=""
  676. icon_getselect(psnup%, 18) cols$ = " -c" 
  677.  cols$=""
  678. icon_getselect(psnup%, 19) border$ = " -d"+
  679. icon_gettext(psnup%, 10) 
  680.  border$=""
  681. icon_getselect(psnup%, 20) scale$ = " -s"+
  682. icon_gettext(psnup%, 11) 
  683.  scale$=""
  684. icon_getselect(psnup%, 13) sheet$ = " -m"+
  685. icon_gettext(psnup%, 8) 
  686.  sheet$=""
  687. icon_getselect(psnup%, 14) page$ = " -b"+
  688. icon_gettext(psnup%, 9) 
  689.  page$=""
  690. w-  pages$ = " -"+
  691. icon_gettext(psnup%, 27)
  692.  pages$ = " -" pages$=""
  693.  Graham - save the custom size here, if a custom on selected
  694.  psize%(psnupwin%,0) = 0 
  695. }0    
  696. get_pagesize( psnupwin%, 0, 5, X%, Y% )
  697. ~*    custom_page%(psnupwin%, 0, 0) = X%
  698. *    custom_page%(psnupwin%, 0, 1) = Y%
  699. *    outsize$ = " -w"+
  700. (X%)+" -h"+
  701. 8    outsize$ = " -p"+
  702. page_name(psize%(psnupwin%,0))
  703.  Graham - save the custom size here, if a custom one is selected
  704.  psize%(psnupwin%,1) = 0 
  705. 0    
  706. get_pagesize( psnupwin%, 1, 3, X%, Y% )
  707. *    custom_page%(psnupwin%, 1, 0) = X%
  708. *    custom_page%(psnupwin%, 1, 1) = Y%
  709. )    insize$ = " -W"+
  710. (X%)+" -H"+
  711. 7    insize$ = " -P"+
  712. page_name(psize%(psnupwin%,1))
  713. w  CL$(psnupwin%) = "psnup "+outsize$+insize$+lscape$+seascape$+swap$+cols$+page$+sheet$+border$+scale$+pages$+" -q"
  714.  Only needs the files now
  715. pstops_CL
  716.  the selections
  717.   border$, size$, pages$, bind$
  718.  Get the variables to the command line
  719. icon_getselect(pstops%, 9) bind$ = " -b" 
  720.  bind$=""
  721. icon_getselect(pstops%, 11) border$ = " -d"+
  722. icon_gettext(pstops%, 10) 
  723.  border$=""
  724. -  pages$ = " "+
  725. icon_gettext(pstops%, 13)
  726.  pages$ = " " pages$=" Default!!!!"
  727.  psize%(pstopswin%,0) = 0 
  728. 1    
  729. get_pagesize( pstopswin%, 0, 5, X%, Y% )
  730. +    custom_page%(pstopswin%, 0, 0) = X%
  731. +    custom_page%(pstopswin%, 0, 1) = Y%
  732. '    size$ = " -w"+
  733. (X%)+" -h"+
  734. 6    size$ = " -p"+
  735. page_name(psize%(pstopswin%,0))
  736. B  CL$(pstopswin%) = "pstops "+size$+bind$+border$+" -q"+pages$
  737. pagespecs(pages$)
  738. get_pagesize(pstopswin%, 0, 5, pw%, ph%)
  739. 7  sc = 216/pw%: sc1 = 184/ph%: 
  740. (sc1 < sc) sc = sc1
  741.   pw% = pw% * sc: ph% = ph% * sc
  742. epsffit_CL
  743.  c$,r$,a$,m$,s$,llx$,lly$,urx$,ury$
  744. icon_getselect(epsffit%, 0) c$ = " -c" 
  745.  c$=""
  746. icon_getselect(epsffit%, 2) m$ = " -m" 
  747.  m$=""
  748. icon_getselect(epsffit%, 3) r$ = " -r" 
  749.  r$=""
  750. icon_getselect(epsffit%, 4) s$ = " -s" 
  751.  s$=""
  752. icon_getselect(epsffit%, 5) a$ = " -a" 
  753.  a$=""
  754. )  llx$=" "+
  755. icon_gettext(epsffit%, 6)
  756. )  lly$=" "+
  757. icon_gettext(epsffit%, 8)
  758. *  urx$=" "+
  759. icon_gettext(epsffit%, 10)
  760. *  ury$=" "+
  761. icon_gettext(epsffit%, 12)
  762.  (llx$ = " ") 
  763.  (lly$ = " ") 
  764.  (urx$ = " ") 
  765.  (ury$ = " ") 
  766. }    fred% = 
  767. wimp_messagebox(
  768. , "Warning", "EpsfFit: Must define x and y coords for lower left and upper right position")
  769. F  CL$(epsffitwin%) = "epsffit "+c$+r$+a$+m$+s$+llx$+lly$+urx$+ury$
  770. psbook_CL
  771.  sig$
  772. *  sig$=" -s"+
  773. icon_gettext(psbook%, 2)
  774.  sig$=" -s" sig$=""
  775. &  CL$(psbookwin%)="psbook -q"+sig$
  776. psresize_CL
  777.  size$,minsize$
  778.  psize%(psresizewin%,0) = 0 
  779. 3    
  780. get_pagesize( psresizewin%, 0, 5, X%, Y% )
  781. -    custom_page%(psresizewin%, 0, 0) = X%
  782. -    custom_page%(psresizewin%, 0, 1) = Y%
  783. '    size$ = " -w"+
  784. (X%)+" -h"+
  785. 8    size$ = " -p"+
  786. page_name(psize%(psresizewin%,0))
  787.  psize%(psresizewin%,1) = 0 
  788. 4    
  789. get_pagesize( psresizewin%, 1, 13, X%, Y% )
  790. -    custom_page%(psresizewin%, 1, 0) = X%
  791. -    custom_page%(psresizewin%, 1, 1) = Y%
  792. )    insize$ = " -W"+
  793. (X%)+" -H"+
  794. :    insize$ = " -P"+
  795. page_name(psize%(psresizewin%,1))
  796. 6  CL$(psresizewin%)="psresize"+size$+insize$+" -q"
  797. psselect_CL
  798.  e$,o$,r$,pages$
  799. icon_getselect(psselect%, 0) e$ = " -e" 
  800.  e$=""
  801. icon_getselect(psselect%, 2) o$ = " -o" 
  802.  o$=""
  803. icon_getselect(psselect%, 3) r$ = " -r" 
  804.  r$=""
  805. .  pages$=" -p"+
  806. icon_gettext(psselect%, 4)
  807.  pages$=" -p" pages$=""
  808. 5  CL$(psselectwin%)="psselect -q"+e$+o$+r$+pages$
  809. which_winnum(win%)
  810.  i% = 0 
  811.  wins%(i%) = win% =i%
  812. H  fred%=
  813. wimp_messagebox(
  814. , "Error!", "Window not found somewhere!")
  815. psnup_setup
  816.  psize%(psnupwin%, 1) = 7 
  817. icon_setcaret(psnup%, 3, -1)
  818.  psize%(psnupwin%, 0) = 7 
  819. %    
  820. icon_setcaret(psnup%, 5, -1)
  821. &    
  822. icon_setcaret(psnup%, 27, -1)
  823. pstops_setup
  824.  width%, height%
  825.  temp% 2048 : 
  826.  Really temp?
  827. %  !pane% = 
  828. win_handle(topspane%)
  829.  "Wimp_GetWindowState",, pane%
  830. #  !temp% = 
  831. win_handle(pstops%)
  832.  "Wimp_GetWindowState",, temp%
  833.   pane%!28 = -1
  834. H  width% = (pane%!12 - pane%!4)/2 : height% = (pane%!16 - pane%!8)/2
  835. '  pane%!12 = width% + temp%!4 + 596
  836. (  pane%!16 = height% + temp%!8 + 218
  837. &  pane%!4 = temp%!4 + 596 - width%
  838. '  pane%!8 = temp%!8 + 218 - height%
  839.   temp%!28 = !pane%
  840.  &400C5,,pane%
  841.  psize%(pstopswin%, 0) = 7 
  842. &    
  843. icon_setcaret(pstops%, 5, -1)
  844. '    
  845. icon_setcaret(pstops%, 10, -1)
  846. get_pagesize(pstopswin%, 0, 5, pw%, ph%)
  847. 7  sc = 216/pw%: sc1 = 184/ph%: 
  848. (sc1 < sc) sc = sc1
  849.   pw% = pw% * sc: ph% = ph% * sc
  850. epsffit_setup
  851. icon_setcaret(epsffit%, 10, -1)
  852. psbook_setup
  853. icon_setcaret(psbook%, 2, -1)
  854. psresize_setup
  855.  psize%(psresizewin%, 0) = 7 
  856. icon_setcaret(psresize%, 5, -1)
  857.  psize%(psresizewin%, 1) = 7 
  858. -(   
  859. icon_setcaret(psresize%, 13, -1)
  860. psselect_setup
  861. icon_setcaret(psselect%, 4, -1)
  862. event_keypress(B%)
  863.  B%!24 <> &0D 
  864. 8#    
  865.  "Wimp_ProcessKey", B%!24
  866. :"    which% = 
  867. win_findwin(!B%)
  868. icon_select(which%, 1)
  869.   x% = TIME
  870.   REPEAT UNTIL TIME = x%+15
  871.  which% = savewin% 
  872. ?/      outfile$ = 
  873. icon_gettext(savewin%, 2)
  874. @!      
  875. outfile$, ".") = 0 
  876. Aj        hello%=
  877. wimp_messagebox(
  878. , "Warning from PSUtils","Drag the file icon to a directory to save")
  879.         
  880.       
  881. D/      
  882. transfer_savefile(outfile$, &FF5, 0)
  883. E        
  884. F&      
  885.  Any of the config windows.
  886.       
  887. call_CL(which%)
  888.       
  889.  mid_save% 
  890. K9        
  891. which_winnum(which%) = curr_selection%) 
  892.           mid_save% = 
  893. M7          
  894. transfer_savefile(config_name$, &FF5, 0)
  895. N4          
  896.  Call the PROC to save the file .....
  897.         
  898.       
  899.         
  900. R!    
  901. icon_deselect(which%, 1)
  902. S4    
  903. (which% = pstops%) 
  904. win_closewin(topspane%)
  905. T<    
  906. win_closewin(which%) : 
  907.  Close the window whatever.
  908. event_closewindow(I%)
  909.  handle%, x%, y%, b%
  910. win_findwin(!I%) = pstopsedit%) 
  911.  x%, y%, b%
  912.  b% = 1 
  913. ^K      
  914.  An attempt to check if the right button was pressed at the time
  915. _%      
  916. win_getsize(pstops%,x%,y%)
  917.       
  918. os_screensize(X%,Y%)
  919. a5      
  920. win_movewin(pstops%,(X%-x%)
  921.  2,(Y%-y%)
  922. b!      
  923. call_setup(pstopswin%)
  924. c        
  925. d&    !I% = 
  926. win_handle(pstopsedit%)
  927.  &400C6,,I%
  928.     big_page_open% = 
  929. g        
  930. win_findwin(!I%) = savewin%) 
  931.  &400C6,,I%: 
  932. l!  handle% = 
  933. win_findwin(!I%)
  934.  Not sure whether to include this?
  935.  mid_save% 
  936. which_winnum(handle%) = curr_selection%) 
  937.       mid_save% = 
  938.     PROCtransfer_savefile(config_name$, &FF5, 0)
  939.     REM Call the PROC to save the file .....
  940.  (handle% = pstops%) 
  941. t'    !pane% = 
  942. win_handle(topspane%)
  943.  &400C6,,pane%
  944. w   !I% = 
  945. win_handle(handle%)
  946.  &400C6,,I%
  947. event_openwindow(I%)
  948.  handle%, width%, height%
  949. }!  handle% = 
  950. win_findwin(!I%)
  951.  (handle% = pstops%) 
  952. '    !pane% = 
  953. win_handle(topspane%)
  954. (    
  955.  "Wimp_GetWindowState",, pane%
  956. -    pane%!28 = -1 : 
  957.  I%!28 : REM 216x184
  958. I    width% = (pane%!12 - pane%!4)/2: height% = (pane%!16 - pane%!8)/2
  959. &    pane%!12 = width% + I%!4 + 596
  960. '    pane%!16 = height% + I%!8 + 218
  961. %    pane%!4 = I%!4 + 596 - width%
  962. &    pane%!8 = I%!8 + 218 - height%
  963.     I%!28 = !pane%
  964.  &400C5,,pane%
  965.  &400C5,,I%  
  966. pagespecs(strin$)
  967.  num_pages, dplus%, rel_end%, pn%, l%, r%, u%, br%, sc%
  968.  bc%, bl%, scale, xoff, yoff, next%, pnext%
  969.  win_w%, win_h%, curr_page%
  970. strin$, ":") = 0 
  971.     spec$ = strin$
  972.     num_pages% = 1
  973. 1    num_pages% = 
  974. strin$, 
  975. strin$, ":")-1))
  976. '    spec$=
  977. strin$, 
  978. strin$, ":")+1)
  979.   !pagespecs% = num_pages%
  980.   dplus% = 
  981. realloc(pagespecs%, num_pages%*20+4) : 
  982.  20 bytes * number of pages
  983. win_getsize(topspane%, win_w%, win_h%)
  984.  i% = 1 
  985.  num_pages%
  986. /    curr_page% = pagespecs% + (i%-1)*20 + 4
  987. 8    !curr_page% = 0 : ?(curr_page% + flags_off%) = 0
  988. J    |(curr_page% + scale_off%) = 0.0 : |(curr_page% + xoff_off%) = 0.0
  989. (    |(curr_page% + yoff_off%) = 0.0 
  990. Q    
  991.  dplus% ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  992.  fplus%
  993.     plus% = 
  994. spec$, "+")
  995.     comma% = 
  996. spec$, ",")
  997. (comma% <> 0) 
  998. >      
  999. spec$, ")") > comma%) 
  1000. spec$, "(") < comma%) 
  1001. 3        comma% = 
  1002. spec$, 
  1003. spec$, ")")+1), ",")
  1004. 9        
  1005.  comma% <> 0 comma% = comma% + 
  1006. spec$, ")") 
  1007.       
  1008.         
  1009. <    
  1010.  ((plus% < comma%) 
  1011.  (plus% <> 0)) 
  1012.  (comma% = 0) 
  1013.       next% = plus%
  1014.       dplus% = 
  1015.         
  1016.       next% = comma%
  1017.       dplus% = 
  1018.         
  1019.  next% > 0 
  1020. '      next_page$ = 
  1021. spec$, next%-1)
  1022. "      spec$ = 
  1023. spec$, next%+1)
  1024.         
  1025. )      next_page$ = spec$ : spec$ = ""
  1026.         
  1027. !    
  1028. next_page$, 1) = "-" 
  1029.       rel_end% = 
  1030. 4      next_page$ = 
  1031. next_page$, 
  1032. (next_page$)-1)
  1033. I      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  1034.  fend%
  1035.         
  1036.     l% = 
  1037. next_page$, "L")
  1038.     r% = 
  1039. next_page$, "R")
  1040.     u% = 
  1041. next_page$, "U")
  1042.     sc% = 
  1043. next_page$, "@")
  1044.     bl% = 
  1045. next_page$, "(")
  1046. @    pnext% = l% : 
  1047.  (pnext% > r%) 
  1048.  (pnext% = 0) pnext% = r%
  1049. 2    
  1050.  (pnext% > u%) 
  1051.  (pnext% = 0) pnext% = u%
  1052. 4    
  1053.  (pnext% > sc%) 
  1054.  (pnext% = 0) pnext% = sc%
  1055. 4    
  1056.  (pnext% > bl%) 
  1057.  (pnext% = 0) pnext% = bl%
  1058.  pnext% = 0 
  1059.       pn% = 
  1060. (next_page$)
  1061.         
  1062. )      pn% = 
  1063. next_page$, pnext%-1))
  1064.         
  1065.     !curr_page% = pn%
  1066.  l% > 0 
  1067.       l% = 
  1068. G      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  1069.         
  1070.       l% = 
  1071.         
  1072.  r% > 0 
  1073.       r% = 
  1074. G      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  1075.         
  1076.       r% = 
  1077.         
  1078.  u% > 0 
  1079.       u% = 
  1080. G      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  1081.         
  1082.       u% = 
  1083.         
  1084.  sc% = 0 
  1085.       scale = 1.0
  1086.         
  1087. (      scale = 
  1088. next_page$, sc%+1))
  1089. H      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  1090.  fsc%
  1091. ,      |(curr_page% + scale_off%) = scale
  1092.         
  1093. 5    
  1094. (bl% <> 0) 
  1095.  ((bl% < next%) 
  1096.  (next% = 0)) 
  1097. %      br$ = 
  1098. next_page$, bl% + 1)
  1099.       bc% = 
  1100. br$, ",")
  1101.       br% = 
  1102. br$, ")")
  1103. @      x$ = 
  1104. br$, 0, bc%-1): y$ = 
  1105. br$, bc%+1, br% - bc% -1 )
  1106.       xoff = 
  1107. parse_dim(x$)
  1108.       yoff = 
  1109. parse_dim(y$)
  1110. I      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  1111.  foff%
  1112. L      |(curr_page% + xoff_off%) = xoff: |(curr_page% + yoff_off%) = yoff
  1113.         
  1114. &    
  1115.  spec$ = "" i% = num_pages%+1
  1116.  Needed in structure:- Number: Page num (Integer , word)
  1117.                        Flags:  l, r, u, sc, same_page, reverse, offset (byte)
  1118.                        Numbers: Scale, xoffset, yoffset (float multibyte)
  1119.  Mem needed = 4 + 1 + 3*5 bytes = 20 bytes per page
  1120. event_redraw(B%)
  1121.  more%, i%, lpw%, lph%, x%, y%, curr_page%, x, y, nw, nh, nw%, nh%, win%, rescale, blx%, bly%, col%
  1122.   win% = !B%
  1123. win_findwin(win%) 
  1124.  topspane%:
  1125.       rescale = sc
  1126.  pstopsedit%
  1127.       rescale = mag%/div%
  1128.  "Wimp_RedrawWindow",,B% 
  1129.  more%
  1130.  more%
  1131. <    
  1132.  Basically take what is currently in pagespecs% and
  1133. =    
  1134.  draw what you think is a reasonable representation!
  1135.     col% = 11
  1136. "    
  1137.  i% = 0 
  1138.  (!pagespecs%-1)
  1139. -      curr_page% = pagespecs% + i%*20 + 4
  1140.       
  1141.       x = 0.0: y = 0
  1142.  The order is:- Shift then Rotate then Scale
  1143.  But I think it is really the other way around
  1144.  Only scale the dimensions not the coords since they are still zero the hero
  1145.       nw = pw%: nh = ph%
  1146. 8      
  1147.  (?(curr_page% + flags_off%) 
  1148.  fsc%) = fsc% 
  1149. .        nw = nw*|(curr_page% + scale_off%)
  1150. .        nh = nh*|(curr_page% + scale_off%)
  1151.       
  1152.       angle% = 0
  1153. 6      
  1154.  (?(curr_page% + flags_off%) 
  1155.  fl%) = fl% 
  1156.          angle% = angle% + 90
  1157. 0        
  1158.  nh, nw: nw = -nw: 
  1159.  Well sort of!
  1160.       
  1161. 6      
  1162.  (?(curr_page% + flags_off%) 
  1163.  fr%) = fr% 
  1164.          angle% = angle% - 90
  1165. 0        
  1166.  nh, nw: nh = -nh: 
  1167.  Well sort of!
  1168.       
  1169. 6      
  1170.  (?(curr_page% + flags_off%) 
  1171.  fu%) = fu% 
  1172. !        angle% = angle% + 180
  1173.         nw = -nw: nh = -nh
  1174.       
  1175. !:      
  1176.  (?(curr_page% + flags_off%) 
  1177.  foff%) = foff% 
  1178. "I        x = |(curr_page% + xoff_off%) : y = |(curr_page% + yoff_off%)
  1179.       
  1180. $       
  1181. font_setangle(angle%)
  1182. %.      x = x*rescale: y = (y - ph%)*rescale
  1183. &*      nh = nh*rescale: nw = nw*rescale
  1184. 'I      x% = x: y% = y: 
  1185.  Just centre the blob on the point of interest
  1186.       nw% = nw: nh% = nh
  1187.       blx% = x%: bly% = y%
  1188. *.      
  1189.  nw% < 0 x% = x% + nw% : nw% = -nw%
  1190. +.      
  1191.  nh% < 0 y% = y% + nh% : nh% = -nh%
  1192. ,(      nw% = x% + nw%: nh% = y% + nh%
  1193.       pages%(i%,0) = x%
  1194.       pages%(i%,1) = y%
  1195.       pages%(i%,2) = nw%
  1196.       pages%(i%,3) = nh%
  1197. 16      
  1198. coord_wintoreal(
  1199. win_findwin(win%), x%, y%)
  1200. 2:      
  1201. coord_wintoreal(
  1202. win_findwin(win%), blx%, bly%)
  1203. 38      
  1204. coord_wintoreal(
  1205. win_findwin(win%), nw%, nh%)
  1206. 46      blx% = blx% + 8*
  1207. (nw): bly% = bly% + 8*
  1208. 5=      
  1209.  (?(curr_page% + flags_off%) 
  1210.  fplus%) <> fplus% 
  1211.         col% = col% + 1
  1212.         
  1213.  col%=16 col% = 8
  1214.       
  1215. 9#      
  1216.  "Wimp_SetColour", col%
  1217.       pages%(i%,5) = col%
  1218. ;#      
  1219.  x%, y%, nw%-x%, nh%-y%
  1220. </      
  1221. font_setcolour(&00000000, &FFFFFF00)
  1222. =;      
  1223. font_plottext(
  1224. (!curr_page%), trin%, blx%, bly%)
  1225. >        
  1226.     !B% = win%
  1227. @*    
  1228.  "Wimp_GetRectangle",,B% 
  1229.  more%
  1230. get_pagesize(win%, one_two%, icon_start%, 
  1231.  w%, 
  1232.  dummy$, w$, h$
  1233.   dummy$ = ""
  1234.  psize%(win%,one_two%) 
  1235. I6      w$ = 
  1236. icon_gettext(wins%(win%), icon_start%)
  1237. J8      h$ = 
  1238. icon_gettext(wins%(win%), icon_start%+1)
  1239.       w% = 
  1240. parse_dim(w$)
  1241.       h% = 
  1242. parse_dim(h$)
  1243.       w% = 595: h% = 842
  1244.       w% = 842: h% = 1191
  1245.       w% = 421: h% = 595
  1246.       w% = 516: h% = 729
  1247.       w% = 612: h% = 792
  1248.       w% = 612: h% = 1008
  1249.       w% = 1224: h% = 792
  1250.       w% = 792: h% = 1224
  1251.       w% = 396: h% = 612
  1252.       w% = 540: h% = 720
  1253.       w% = 612: h% = 936
  1254.       w% = 610: h% = 780
  1255.       w% = 720: h% = 1008
  1256. parse_dim(
  1257.  dim$)
  1258.  c%, p%, i%, m%, u%, s%, error_cond%
  1259.   error_cond% = 
  1260.   u% = 0
  1261.   s% = 999
  1262.   c% = 
  1263. dim$, "c")
  1264.   p% = 
  1265. dim$, "p")
  1266.   i% = 
  1267. dim$, "i")
  1268.   m% = 
  1269. dim$, "m")
  1270.  (c% <> 0) u% = 1 : s% = c%
  1271.  (p% <> 0) 
  1272.  (p% < s%) u% = 2 : s% = p%
  1273.  (i% <> 0) 
  1274.  (i% < s%) u% = 3 : s% = i%
  1275.  (m% <> 0) 
  1276.  (m% < s%) u% = 4 : s% = m%
  1277. z(      u% = 1: dim$ = 
  1278. (dim$))+"pt"
  1279.       = 
  1280. (dim$)
  1281. }&      
  1282. dim$, s%+1, 1) <> "m") 
  1283.         error_cond% = 
  1284.       
  1285. *        dim$ = 
  1286. dim$, s%-1)))+"cm"
  1287. %        = 
  1288. dim$, s%-1))*72/2.54
  1289.       
  1290. &      
  1291. dim$, s%+1, 1) <> "t") 
  1292.         error_cond% = 
  1293.       
  1294. *        dim$ = 
  1295. dim$, s%-1)))+"pt"
  1296.         = 
  1297. dim$, s%-1))
  1298.       
  1299. &      
  1300. dim$, s%+1, 1) <> "n") 
  1301.         error_cond% = 
  1302.       
  1303. *        dim$ = 
  1304. dim$, s%-1)))+"in"
  1305.          = 
  1306. dim$, s%-1))*72
  1307.       
  1308. &      
  1309. dim$, s%+1, 1) <> "m") 
  1310.         error_cond% = 
  1311.       
  1312. *        dim$ = 
  1313. dim$, s%-1)))+"mm"
  1314. %        = 
  1315. dim$, s%-1))*72/25.4
  1316.       
  1317.  error_cond% 
  1318.     dim$ = dim$
  1319. ]    fred% = 
  1320. wimp_messagebox(
  1321. , "Error", "Error: Invalid dimension specifier somewhere!")
  1322.     = 0
  1323. N  fred% = 
  1324. wimp_messagebox(
  1325. , "Error", "Can't finish this function here!")
  1326. page_name(page_num%)
  1327.  page_num% 
  1328. [      fred% = 
  1329. wimp_messagebox(
  1330. , "Error", "Shouldn't have called page_name that way!")
  1331.       = ""
  1332.       = "a4"
  1333.       = "a3"
  1334.       = "a5"
  1335.       = "b5"
  1336.       = "letter"
  1337.       = "legal"
  1338.       = "ledger"
  1339.       = "tabloid"
  1340.       = "statement"
  1341.       = "executive"
  1342.       = "folio"
  1343.       = "quarto"
  1344.       = "10x14"
  1345. bigpage_click(B%)
  1346.  l%,r%,b%,t%,x%,y%,w%,h%,i%
  1347.  B% contains all details of the mouse click
  1348.  Find where the click was and decide which page was clicked on.
  1349. x% = !B% : y% = B%!4
  1350. coord_realtowin( pstopsedit%, x%, y% )
  1351. hitwin% = -1
  1352.  Find the window number (logical number rather than physical - make sense?)
  1353.  i% = 0 
  1354.  !pagespecs%-1
  1355.  Check L, R, T and then B
  1356.  ( ( y% >= pages%(i%,1) ) 
  1357.  ( y% < pages%(i%,3) ) ) 
  1358. O    
  1359. ( x% - pages%(i%,0) ) <= 4 ) 
  1360. ( x% - pages%(i%,2) ) < 4 ) ) 
  1361. '      hitwin%=i% : i% = !pagespecs%
  1362.         
  1363.  ( ( x% >= pages%(i%,0) ) 
  1364.  ( x% < pages%(i%,2) ) 
  1365.  ( hitwin% = -1 ) ) 
  1366. O    
  1367. ( y% - pages%(i%,1) ) <= 4 ) 
  1368. ( y% - pages%(i%,3) ) < 4 ) ) 
  1369. '      hitwin%=i% : i% = !pagespecs%
  1370.         
  1371.  hitwin% = -1 
  1372.  Possibly un highlight the previously selected window of something like that
  1373.  hello% = FNwimp_messagebox( FALSE, "Selected page", "Page number "+STR$(hitwin%)+" selected "+STR$(B%!8) )
  1374.  "Wimp_SetColour", 0+(3<<4)
  1375. l% = pages%(i%,0)
  1376. "r% = pages%(i%,2)-pages%(i%,0)
  1377. b% = pages%(i%,1)
  1378. "t% = pages%(i%,3)-pages%(i%,1)
  1379. $!B% = 
  1380. win_handle( pstopsedit% )
  1381. 7B%!4 = l% : B%!8 = t% : B%!12 = r%+2 : B%!16 = b%-2
  1382.  &400C9,,B% 
  1383.  more%
  1384. coord_wintoreal( pstopsedit%, l%, b% )
  1385. coord_wintoreal( pstopsedit%, r%, t% )
  1386.  more%
  1387.  l%,b%,r%-l%,t%-b%
  1388.  &400CA,,B% 
  1389.  more%
  1390. memory(Y%,S%)
  1391.  P%,D%,A%,B%,C%,E%,F%,G%,H%,I%,J%,K%,L%,M%,N%,O%,Q%,R%,T%,U%,V%,Z%,X%,W%
  1392.  copyright$,g%,h%,i%,l%,m%,n%,o%
  1393. Gcopyright$="Dynamic memory allocation routines, 
  1394.  Ian Palmer, 1993"
  1395.  _mem_code% 559
  1396. 0_mem_error%=Y%:_memdim%=S%:
  1397.  &51 
  1398.  _mpsize%
  1399.  &400EC,-1,-1 
  1400.  _mtop%:_mtop%+=&8000
  1401.  Z%=0 
  1402.  2:P%=_mem_code%:[OPT Z%
  1403. !B A%:B B%:B C%:B D%:B R%:B W%
  1404. H.A%:ADR R4,_memory%:LDR R1,[R4]:.E%:CMP R1,#0:BEQ F%:LDR R2,[R1,#-4]
  1405. LCMP R2,R0:BGE G%:MOV R4,R1:LDR R1,[R1]:B E%:.F%:MOV R0,#0:ADR R1,_memrv%
  1406. ESTR R0,[R1]:MOV PC,R14:.G%:LDR R2,[R1]:STR R2,[R4]:ADR R0,_memrv%
  1407. STR R1,[R0]:MOV PC,R14
  1408. M.B%:LDR R5,[R0,#-4]:ADD R6,R5,R0:ADD R6,R6,#4:ADR R4,_memory%:LDR R1,[R4]
  1409. B.H%:CMP R1,#0:BEQ I%:LDR R2,[R1,#-4]:ADD R3,R2,R1:ADD R3,R3,#4
  1410. QCMP R3,R0:BEQ J%:CMP R6,R1:BEQ K%:CMP R1,R0:BGT I%:MOV R4,R1:LDR R1,[R1]:B H%
  1411. B.I%:STR R0,[R4]:STR R1,[R0]:B L%:.J%:ADD R5,R5,R2:ADD R5,R5,#4
  1412. JSTR R5,[R1,#-4]:MOV R0,R1:LDR R1,[R1]:CMP R6,R1:BNE L%:LDR R2,[R1,#-4]
  1413. I.K%:ADD R5,R5,R2:ADD R5,R5,#4:STR R5,[R0,#-4]:LDR R1,[R1]:STR R1,[R0]
  1414. 9STR R0,[R4]:.L%:ADR R1,_memrv%:STR R0,[R1]:MOV PC,R14
  1415. I.C%:ADR R1,_memory%:.M%:LDR R2,[R1]:CMP R2,#0:BEQ N%:CMP R2,R0:BEQ O%
  1416. NMOVLT R1,R2:BLT M%:.N%:MOV R1,#0:.O%:ADR R0,_memrv%:STR R1,[R0]:MOV PC,R14
  1417. H.R%:ADR R4,_memory%:LDR R2,[R4]:.T%:CMP R2,#0:BEQ U%:LDR R3,[R2,#-4]
  1418. JADD R3,R3,R2:CMP R3,R0:BEQ V%:MOV R4,R2:LDR R2,[R2]:B T%:.U%:MOV R2,#0
  1419. I.V%:ADR R1,_memrv%:STR R2,[R1]:ADR R1,_memrv2%:STR R4,[R1]:MOV PC,R14
  1420. B.W%:ADR R1,_memory%:MOV R0,#0:LDR R2,[R1]:.Y%:CMP R2,#0:BEQ S%
  1421. 1LDR R3,[R2,#-4]:ADD R0,R0,R3:LDR R2,[R2]:B Y%
  1422. -.S%:ADR R1,_memrv%:STR R0,[R1]:MOV PC,R14
  1423.     B.D%:STMFD R13!,{R8-R10,R14}:CMP R0,#0:LDMEQFD R13!,{R8-R10,PC}
  1424. -CMP R1,R2:LDMEQFD R13!,{R8-R10,PC}:BLT l%
  1425. H.g%:SUBS R0,R0,#32:BLT h%:LDMIA R1!,{R3-R10}:STMIA R2!,{R3-R10}:B g%
  1426. Q.h%:ADDS R0,R0,#32:.i%:LDMEQFD R13!,{R8-R10,PC}:LDR R4,[R1],#4:STR R4,[R2],#4
  1427. SUBS R0,R0,#4:B i%
  1428. !.l%:ADD R1,R1,R0:ADD R2,R2,R0
  1429. H.m%:SUBS R0,R0,#32:BLT n%:LDMDB R1!,{R3-R10}:STMDB R2!,{R3-R10}:B m%
  1430. D.n%:ADDS R0,R0,#32:.o%:LDMEQFD R13!,{R8-R10,PC}:LDR R4,[R1,#-4]!
  1431. 'STR R4,[R2,#-4]!:SUBS R0,R0,#4:B o%
  1432. ._memory% EQUD 0
  1433. ._memrv% EQUD 0
  1434. ._memrv2% EQUD 0
  1435. _more_memory(S%)
  1436.  M%,L%,A%,X%,Y%,Z%:M%=0
  1437.  _memdim% 
  1438. M  A%=
  1439.  _mem_code%+16:L%=!_memrv%:
  1440.  L%<>0 
  1441.  S%-=!(L%-4)-4:!!_memrv2%=!L%
  1442.  S%<(
  1443. -2048) 
  1444.  M% S%-1:!M%=S%-4:
  1445.  L%<>0 
  1446.  M%=L%-4:!M%=S%+!(L%-4)
  1447. T  A%=_mtop%:
  1448.  _mem_code%+16:L%=!_memrv%:
  1449.  L%<>0 
  1450.  S%-=!(L%-4)-4:!(!_memrv2%)=!L%
  1451.  &400EC,-1,-1 
  1452.  X%,Y%,Z%:
  1453.  S%<Z% 
  1454.  k    
  1455.  &400EC,X%+S%,Y% 
  1456.  Z%:M%=X%+&8000:!M%=Z%-X%-4:_mtop%=Z%+&8000:
  1457.  L%<>0 
  1458.  M%=L%-4:!M%=Z%-X%+!(L%-4)
  1459.  M%<>0 
  1460.  M%+=4
  1461. _less_memory
  1462.  A%,B%,L%,C%,S%,N%,D%
  1463. A%=_mtop%:
  1464.  _mem_code%+16
  1465. )+B%=!_memrv%:C%=!_memrv2%:B%-=4:L%=4+!B%
  1466. *;D%=(L% 
  1467.  _mpsize%)*_mpsize%:N%=L%-D%:S%=_mtop%-D%-&8000
  1468.  &400EC,S%,-1 
  1469.  S%:_mtop%=S%+&8000
  1470.  N%>7 
  1471.  !B%=N%-4:
  1472.  !C%=0
  1473. font_init
  1474. 02__font_angle=0:__font_xflip%=
  1475. :__font_yflip%=
  1476.  __font_transform% 24,__font_bbox% 36
  1477. 24__font_transform%!0=&10000:__font_transform%!4=0
  1478. 35__font_transform%!8=0:__font_transform%!12=&10000
  1479. 41__font_transform%!16=0:__font_transform%!20=0
  1480. _font_settransform
  1481. 80__font_transform%!0=
  1482. (__font_angle)*&10000
  1483. 90__font_transform%!4=
  1484. (__font_angle)*&10000
  1485. :1__font_transform%!8=-
  1486. (__font_angle)*&10000
  1487. ;1__font_transform%!12=
  1488. (__font_angle)*&10000
  1489.  __font_xflip% __font_transform%!8=-(__font_transform%!8):__font_transform%!12=-(__font_transform%!12)
  1490.  __font_yflip% __font_transform%!0=-(__font_transform%!0):__font_transform%!4=-(__font_transform%!4)
  1491. grj_wimp_init(T$,I$,L%,S%,V%,H%)
  1492.  grj_name% 256, grj_valid% 256
  1493.  B%,C%,X%,Y%,M%,xp%,yp%,wfhand%:
  1494.  S%=0 
  1495.  S%=512:
  1496.  S%<256 S%=256
  1497. CS_wimp_task$=T$:_wimp_buffer%=
  1498. malloc(S%):B%=
  1499. malloc(38+
  1500. (I$)):_wimp_iconbar%=B%
  1501.  &400C0,V%,&4B534154,T$,H% 
  1502.  _wimp_version%,_wimp_handle%
  1503. font_init
  1504.  This is needed for the iconbar text initialsation
  1505.  &20023,"Wimp$Font",_wimp_buffer%,S%,0,0 
  1506.  ,,len%,,type% ; NoFont%
  1507.  ( NoFont% 
  1508.  1 ) = 0 
  1509. I   ?(_wimp_buffer%+len%) = 13
  1510.   wfname$ = $_wimp_buffer%
  1511.   xp% = 
  1512.  wfname$, "\F" )
  1513. ( xp% <> 0 ) wfname$ = 
  1514.  wfname$, xp%+2 )
  1515.   xp% = 
  1516.  wfname$, "\E" )
  1517. ( xp% <> 0 ) wfname$ = 
  1518.  wfname$, 0, xp%-1 )
  1519.  &23,"Wimp$FontWidth",_wimp_buffer%,S%,0,0 
  1520.  ,,len%,,type%
  1521. P   ?(_wimp_buffer%+len%) = 13
  1522.   temp$ = $_wimp_buffer%
  1523.   yp%=
  1524. (temp$)
  1525.   $_wimp_buffer% = wfname$
  1526. T%  ?(_wimp_buffer%+
  1527. (wfname$)) = 0
  1528.  &40081,,_wimp_buffer%,yp%,yp%,0,0 
  1529.  wfhand%
  1530.  I$<>"" 
  1531.  &400E9,40,,I$ 
  1532.  ,,,X%,Y%,,M%
  1533.  &35,M%,4 
  1534.  ,,C%:X%=X%<<C%
  1535.  &35,M%,5 
  1536.  ,,C%:Y%=Y%<<C%
  1537.  ( NoFont% 
  1538.  1 ) = 0 
  1539. \E    
  1540.  &40085,,"PsResize",&7FFFFFFF,&7FFFFFFF,-1,&7FFFFFFF 
  1541.  ,,X%
  1542.  &40088,,X%,Y% 
  1543.     X% = 128
  1544.   !B%=-2:
  1545.  !B%=-1
  1546.  GRJ - CHANGE FOR PSUTILS!
  1547.   B%!4=0:B%!8=-16 : 
  1548.  was 0
  1549. d%  B%!12=X%:B%!16=Y%+20 : 
  1550.  was Y%
  1551. e"  B%!20=&1700210B : 
  1552.  was 2102
  1553. f!  B%!24=grj_name% : 
  1554.  B%+36+1
  1555. g#  B%!28 = grj_valid% : 
  1556.  B%+36:
  1557.   B%!32=
  1558. (I$)+1
  1559.   $(B%+36)="s"+I$
  1560.   $(grj_name%) = I$
  1561.   $(grj_valid%) = "s"+I$
  1562.  B%!28=1:B%!32=LEN(I$)+1
  1563.  &400C2,,B% 
  1564.  _wimp_icon%
  1565.  ( NoFont% 
  1566.  1 ) = 0 
  1567.  &40082,wfhand%
  1568. grj_update_bartext(T$)
  1569.  B%,C%,X%,Y%,M%
  1570.   B%=_wimp_buffer%
  1571.  Lets try to get thewidth of the string - somewhat assumescurent font is
  1572.  desktop font
  1573.   $(grj_name%) = T$
  1574. z,  !B%=-1:B%!4=_wimp_icon%:B%!8=0:B%!12=0
  1575.  &400CD,,B%
  1576. wimp_error(F%,E%,M$)
  1577.  B%,R%:B%=_wimp_buffer%
  1578. %!B%=E%:$(B%+4)=M$:?(B%+4+
  1579. (M$))=0
  1580.  &400DF,B%,1,_wimp_task$
  1581. wimp_quit
  1582.  &400DF,B%,3,_wimp_task$ 
  1583.  R%=2 
  1584. wimp_quit
  1585. *|update
  1586. wimp_quit:
  1587.          *** update block ***
  1588.  I%=0 
  1589.  _temp_fonts%?I% 
  1590.  "Font_LoseFont",I%
  1591.  &400DD,_wimp_handle%,&4B534154
  1592. *|downdate
  1593. malloc(A%)
  1594.  M%,S%
  1595. -S%=A%:A%=12+(A% 
  1596.  16)*16:
  1597.  A%<S% 
  1598.  A%+=16
  1599.  _mem_code%:M%=!_memrv%
  1600.  M%=0 
  1601.   M%=
  1602. _more_memory(A%+4)
  1603.  M%<>0 
  1604.  S%=!(M%-4):
  1605.  S%-A%>15 
  1606.  !(M%-4)=A%:
  1607. add_free(M%+A%,S%-A%)
  1608.  M%=0 
  1609.  _mem_error% 
  1610.  11,"Can't allocate memory"
  1611. win_init(E%)
  1612. 4_win_list%=
  1613. malloc(4*E%):E%=
  1614. size_of(_win_list%)
  1615.  A%=0 
  1616.  E%-1 
  1617.  4:!(_win_list%+A%)=0:
  1618. font_gethandle(font$,x,y)
  1619.  font%
  1620.  "Font_FindFont",,font$,x*16,y*16,0,0 
  1621.  font%
  1622. =font%
  1623. temp_init
  1624. _temp_list%=0
  1625. _temp_spritearea%=0
  1626. _temp_fonts%=
  1627. malloc(256)
  1628.  I%=0 
  1629.  255:_temp_fonts%?I%=0:
  1630. *|update
  1631. transfer_init
  1632. _transfer_type%=0
  1633. _transfer_file$=""
  1634. _transfer_size%=0
  1635. _transfer_ref%=0
  1636. _transfer_dragging%=
  1637. _wimp_buffer%!0=1
  1638. _wimp_buffer%!4=2
  1639. _wimp_buffer%!8=3
  1640. _wimp_buffer%!12=5
  1641. _wimp_buffer%!16=6
  1642. _wimp_buffer%!20=7
  1643. _wimp_buffer%!24=&80142
  1644. _wimp_buffer%!28=&80144
  1645. _wimp_buffer%!32=&80145
  1646. _wimp_buffer%!36=0
  1647. wimp_addmessages(_wimp_buffer%)
  1648. _transfer_wantmess(mess%)
  1649.  mess% 
  1650.  1,2,3,5,6,&80144,&80145: =
  1651. event_transfermessage(block%)
  1652.  buffer%,size%,mess%
  1653. ?(block%+!block%)=0
  1654.  block%!16 
  1655. F    
  1656. transfer_willload(block%!40,
  1657.  block%!8<>_transfer_ref% 
  1658. 1      
  1659. os_putstring(block%+44,"<Wimp$Scrap>")
  1660.       block%!36=-1
  1661.       block%!12=block%!8
  1662.       block%!16=2
  1663.       !block%=60
  1664. 2      
  1665.  "Wimp_SendMessage",17,block%,block%!4
  1666.         
  1667. $    
  1668.  block%!12=_transfer_ref% 
  1669. #      block%!36=_transfer_size%
  1670.       block%!12=block%!8
  1671.       block%!16=3
  1672. =      
  1673.  "Wimp_SendMessage",18,block%,block%!20,block%!24
  1674. V      
  1675. transfer_savefile(
  1676. os_getstring(block%+44),_transfer_type%,(block%!36<>-1))
  1677. !      _transfer_ref%=block%!8
  1678.       
  1679. menu_remove
  1680.         
  1681. E    
  1682.  block%!4<>_wimp_handle% 
  1683. transfer_willload(block%!40,
  1684.       block%!12=block%!8
  1685.       block%!16=4
  1686. 2      
  1687.  "Wimp_SendMessage",17,block%,block%!4
  1688. i      
  1689. transfer_loadfile(
  1690. os_getstring(block%+44),block%!40,
  1691. os_getstring(block%+44)<>"<Wimp$Scrap>")
  1692.         
  1693. +    
  1694. transfer_willload(block%!40,
  1695.       block%!12=block%!8
  1696.       block%!16=4
  1697. 2      
  1698.  "Wimp_SendMessage",17,block%,block%!4
  1699. B      
  1700. transfer_loadfile(
  1701. os_getstring(block%+44),block%!40,
  1702.  &80145:
  1703.  block%!12 
  1704.           
  1705. _transfer_wantack(mess%)
  1706.  mess% 
  1707.  3,7,&80142: =
  1708. event_transferacknowledge(block%)
  1709.  dummy%
  1710.  block%!16 
  1711. #    
  1712.  block%!8=_transfer_ref% 
  1713. 5      
  1714. os_getstring(block%+44)="<Wimp$Scrap>" 
  1715. -        
  1716.  "OS_CLI","Remove <Wimp$Scrap>"
  1717.       
  1718. d      dummy%=
  1719. wimp_messagebox(
  1720. ,"Error from "+_wimp_task$,"Data transfer failed: Receiver died")
  1721.             
  1722. event_savedrag(block%)
  1723.  flag%
  1724.  _wimp_version%>=300 
  1725.  "OS_Byte",161,28 
  1726.  ,,flag%
  1727.   flag%=((flag% 
  1728.  2) = 2)
  1729.   flag%=
  1730.  flag% 
  1731.  "DragASprite_Stop"
  1732.  "Wimp_DragBox",,-1
  1733. _transfer_dragging%=
  1734. _transfer_file$,".")
  1735. ?  _transfer_file$=
  1736. _transfer_file$,
  1737. _transfer_file$,".")+1)
  1738.  "Wimp_GetPointerInfo",,_wimp_buffer%
  1739. G_wimp_buffer%!20=_wimp_buffer%!12:_wimp_buffer%!24=_wimp_buffer%!16
  1740.  D_wimp_buffer%!28=!_wimp_buffer%:_wimp_buffer%!32=_wimp_buffer%!4
  1741. !$_wimp_buffer%!36=_transfer_size%
  1742. "$_wimp_buffer%!40=_transfer_type%
  1743. os_putstring(_wimp_buffer%+44,_transfer_file$)
  1744. $)_wimp_buffer%!12=0:_wimp_buffer%!16=1
  1745. %4!_wimp_buffer%=44+4*((
  1746. (_transfer_file$)+4) 
  1747.  "Wimp_SendMessage",18,_wimp_buffer%,_wimp_buffer%!20,_wimp_buffer%!24
  1748. '"_transfer_ref%=_wimp_buffer%!8
  1749. *|downdate
  1750. *|update
  1751. wimp_poll(M%,T%,P%):
  1752.       *** update block ***
  1753.  R%,I%,Q%
  1754.  T%=0 
  1755.  &400C7,M%,_wimp_buffer%,,P% 
  1756.  &42 
  1757.  Q%:Q%=Q%+T%
  1758.  &400E1,M%,_wimp_buffer%,Q%,P% 
  1759. :I%=_wimp_buffer%
  1760.  1 : 
  1761. event_redraw(I%)
  1762.  2 : 
  1763. event_openwindow(I%)
  1764.  3 : 
  1765. event_closewindow(I%)
  1766.  6 : 
  1767.  I%!12=-2 
  1768.              Q%=I%!8
  1769. 95             
  1770.  (Q% 
  1771. event_iconbarmenu(!I%)
  1772. :6             
  1773.  (Q% 
  1774. event_iconbaradjust(I%)
  1775. ;6             
  1776.  (Q% 
  1777. event_iconbarselect(I%)
  1778.            
  1779.              Q%=0
  1780. >-             
  1781.  Q%=0 
  1782. event_mouseclick(I%)
  1783.            
  1784.  7 : 
  1785.  _transfer_dragging% 
  1786. A$             
  1787. event_savedrag(I%)
  1788.            
  1789.  8 : 
  1790. event_keypress(I%)
  1791.  9 : 
  1792. event_menuselection(I%):
  1793. menu_keepopen
  1794.  17,18: 
  1795. _transfer_wantmess(I%!16) 
  1796. F.                
  1797. event_transfermessage(I%)
  1798.               
  1799. H&                
  1800. event_message(I%)
  1801.               
  1802.  19: 
  1803. _transfer_wantack(I%!16) 
  1804. K/             
  1805. event_transferacknowledge(I%)
  1806.            
  1807. *|downdate
  1808. temp_readfile(F$,E%)
  1809.  C%,A%,D%,N%,T%,F%,Z%,H%,I%
  1810.  C%=0 
  1811. wimp_error(1,214,"Can't open template file "+F$)
  1812.  A%=0 
  1813.  15:D%=
  1814. :T%=0:Z%=
  1815. malloc(E%)
  1816.  A%=0 
  1817.  23:Z%?A%=
  1818.  !Z% 
  1819. X+  N%=
  1820. malloc(32):!N%=T%:T%=N%:N%!4=Z%!4
  1821.  A%=0 
  1822.  11:F%=?(Z%+12+A%):
  1823.  F%=0 
  1824.  ?(Z%+A%+12)=13
  1825. :?(Z%+24)=13:$(N%+16)=
  1826. tolower($(Z%+12))
  1827.  !Z%=0:
  1828. D%=T%:A%=Z%
  1829. malloc(256)
  1830.  &400D9,,F$
  1831.  I%=0 
  1832.  255:H%?I%=0:
  1833.  I%  
  1834.   N%=
  1835. malloc(D%!4):D%!8=N%
  1836.  &400DB,,N%,A%,A%+E%,H%,$(D%+16),0 
  1837.  ,,C%:F%=4+C%-A%
  1838. dB  C%=
  1839. malloc(F%):D%!12=C%:
  1840.  &400DB,,N%,C%,C%+F%,H%,$(D%+16),0
  1841.  !D%=0 
  1842.  !D%=_temp_list%:_temp_list%=T%:D%=0:
  1843.  D%=!D%
  1844.  I%=0 
  1845. g$    
  1846.  H%?I% 
  1847.  _temp_fonts%?I%+=1
  1848.  _temp_spritearea% 
  1849.     N%!64=_temp_spritearea%
  1850.     I%=N%!84
  1851.  I%>0
  1852. m+      
  1853.  (!(N%+104+32*I%) 
  1854.  &103)=&102 
  1855. n-        !(N%+112+32*I%)=_temp_spritearea%
  1856.       
  1857.       I%-=1
  1858. q        
  1859.  &400DA:
  1860. free(Z%)
  1861. free(H%)
  1862. win_createwin(N$)
  1863. z(D%=
  1864. temp_copy(N$):
  1865. win_createwin(D%)
  1866. win_resize(W%,X%,Y%)
  1867.  B%:B%=_wimp_buffer%:!B%=!(W%-8)
  1868.  &400CB,,B%:B%!12=B%!4+X%:B%!16=B%!8+Y%:
  1869.  &400C5,,B%
  1870. win_closewin(W%)
  1871. 3!_wimp_buffer%=!(W%-8):
  1872.  &400C6,,_wimp_buffer%
  1873. icon_shade(W%,I%)
  1874. -!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%
  1875. 4_wimp_buffer%!8=&400000:_wimp_buffer%!12=&400000
  1876.  &400CD,,_wimp_buffer%
  1877. icon_settext(W%,I%,T$)
  1878.  cw%,ci%,cx%,cy%,cp%
  1879. F!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%:
  1880.  &400CE,,_wimp_buffer%
  1881.  (_wimp_buffer%!24 
  1882.  1)=0 
  1883.  (_wimp_buffer%!24 
  1884.  256) 
  1885. os_putstring(_wimp_buffer%!28,
  1886. T$,_wimp_buffer%!36))
  1887.  &400D3,,_wimp_buffer%+128
  1888. Ecw%=_wimp_buffer%!128:ci%=_wimp_buffer%!132:cx%=_wimp_buffer%!136
  1889. /cy%=_wimp_buffer%!140:cp%=_wimp_buffer%!148
  1890.  cw%=W%!-8 
  1891.  ci%=I% 
  1892.  cp% > 
  1893. (S$) 
  1894.  cp% = 
  1895.  &400D2,cw%,ci%,cx%,cy%,-1,cp%
  1896. (_wimp_buffer%!8=0:_wimp_buffer%!12=0
  1897.  &400CD,,_wimp_buffer%
  1898. menu_init(N%)
  1899. ;menu_tick=1:menu_dotted=2:_wimp_menu%=
  1900. malloc((N%+1)*4)
  1901. 2_wimp_oldmenu%=0:_wimp_oldmx%=0:_wimp_oldmy%=0
  1902. 7!_wimp_menu%=N%:
  1903.  A%=1 
  1904.  N%:!(_wimp_menu%+4*A%)=0:
  1905. menu_header(T$,M%,N%)
  1906.  P%,A%
  1907. P%=!(_wimp_menu%+4*(M%+1))
  1908.  P%=0 
  1909. 5  P%=
  1910. malloc(32+24*N%):!(_wimp_menu%+4*(M%+1))=P%
  1911. size_of(P%)<(32+24*N%) 
  1912. realloc(P%,32+24*N%):!(_wimp_menu%+4*(M%+1))=P%
  1913. F$P%=T$:P%?
  1914. (T$)=0:P%!12=&70207:P%!16=16*(1+
  1915. (T$)):P%!20=44:P%!24=0
  1916.  A%=0 
  1917.  N%-2:!(P%+28+A%*24)=0:
  1918. :!(P%+4+N%*24)=128
  1919. menu_additem(M%,N%,I$,F%)
  1920.  P%,W%
  1921. MP%=!(_wimp_menu%+4*(M%+1)):
  1922.  P%=0 
  1923.  0,"Menu number "+
  1924. (M%)+" undefined"
  1925. @!(P%+28+N%*24)=(!(P%+28+N%*24) 
  1926.  &F0) 
  1927.  F%:!(P%+32+N%*24)=-1
  1928. D!(P%+36+N%*24)=&7000021:$(P%+40+N%*24)=I$:?(P%+40+N%*24+
  1929. (I$))=0
  1930. )W%=16*(1+
  1931. (I$)):
  1932.  W%>P%!16 
  1933.  P%!16=W%
  1934. menu_submenu(M%,N%,S%)
  1935.  P%:P%=!(_wimp_menu%+4*(M%+1))
  1936. &!(P%+28+N%*24)=!(P%+28+N%*24) 
  1937. *!(P%+32+N%*24)=!(_wimp_menu%+4*(S%+1))
  1938. menu_subwindow(M%,N%,S%)
  1939.  P%:P%=!(_wimp_menu%+4*(M%+1)):!(P%+32+N%*24)=!(S%-8)
  1940. toupper(S$)
  1941.  R$,A%,C%,L%:L%=
  1942. (S$):R$="":
  1943.  L%=0 
  1944. A%=1 
  1945.  L%:C%=
  1946. S$,A%,1)):
  1947.  C%>96 
  1948.  C%<123 
  1949.  C%-=32
  1950. (C%):
  1951. menu_untick(M%,N%)
  1952.  P%:P%=!(_wimp_menu%+4*(M%+1))+28+N%*24:!P%=!P% 
  1953.  &FFFFFFFE
  1954. menu_tick(M%,N%)
  1955.  P%:P%=!(_wimp_menu%+4*(M%+1))+28+N%*24:!P%=!P% 
  1956. icon_unshade(W%,I%)
  1957. -!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%
  1958. ._wimp_buffer%!8=0:_wimp_buffer%!12=&400000
  1959.  &400CD,,_wimp_buffer%
  1960. win_getsize(W%,
  1961.  B%:B%=_wimp_buffer%:!B%=!(W%-8)
  1962.  &400CB,,B%:X%=B%!12-B%!4:Y%=B%!16-B%!8
  1963. os_screensize(
  1964.  F%,P%
  1965.  &35,-1,4 
  1966.  ,,F%:
  1967.  &35,-1,11 
  1968.  ,,P%:X%=P%<<F%
  1969.  &35,-1,5 
  1970.  ,,F%:
  1971.  &35,-1,12 
  1972.  ,,P%:Y%=P%<<F%
  1973. win_movewin(W%,X%,Y%)
  1974.  x%,y%,B%:B%=_wimp_buffer%:!B%=!(W%-8)
  1975.  &400CB,,B%:x%=B%!12-B%!4:y%=B%!16-B%!8
  1976. +B%!4=X%:B%!8=Y%:B%!12=X%+x%:B%!16=Y%+y%
  1977.  &400C5,,B%
  1978. win_handle(W%)
  1979. =!(W%-8)
  1980. win_getextent(W%,
  1981.  B%:B%=_wimp_buffer%:!B%=!(W%-8)
  1982.  &400CC,,B%:x%=B%!44:y%=B%!48:X%=B%!52:Y%=B%!56
  1983. icon_setcaret(W%,I%,X%)
  1984.  X%=-1 
  1985. icon_gettext(W%,I%))
  1986.  &400D2,!(W%-8),I%,0,0,-1,X%
  1987. transfer_startdrag(file$,type%,size%,win%,icon%)
  1988.  flag%,xmin%,xmax%,ymin%,ymax%,xsize%,ysize%,sprite$
  1989. $!_wimp_buffer%=
  1990. win_handle(win%)
  1991.  "Wimp_GetWindowInfo",,_wimp_buffer%
  1992. 8xmin%=_wimp_buffer%!4+!(_wimp_buffer%+92+32*icon%+0)
  1993. 8xmax%=_wimp_buffer%!4+!(_wimp_buffer%+92+32*icon%+8)
  1994. [ymin%=_wimp_buffer%!8+!(_wimp_buffer%+92+32*icon%+4)+(_wimp_buffer%!16-_wimp_buffer%!8)
  1995. \ymax%=_wimp_buffer%!8+!(_wimp_buffer%+92+32*icon%+12)+(_wimp_buffer%!16-_wimp_buffer%!8)
  1996. os_screensize(xsize%,ysize%)
  1997.  _wimp_version%>=300 
  1998.  "OS_Byte",161,28 
  1999.  ,,flag%
  2000.   flag%=((flag% 
  2001.  2) = 2)
  2002.   flag%=
  2003.  flag% 
  2004.   _wimp_buffer%!0=xmin%
  2005.   _wimp_buffer%!4=ymin%
  2006.   _wimp_buffer%!8=xmax%
  2007.   _wimp_buffer%!12=ymax%
  2008. H  sprite$="file_":
  2009.  type%<&100 sprite$+="0":
  2010.  type%<&10 sprite$+="0"
  2011.   sprite$+=
  2012. ~(type%)
  2013.  "DragASprite_Start",%11000101,1,sprite$,_wimp_buffer%,0
  2014.   !_wimp_buffer%=0
  2015.   _wimp_buffer%!4=5
  2016. 2  _wimp_buffer%!8=xmin%:_wimp_buffer%!12=ymin%
  2017. 3  _wimp_buffer%!16=xmax%:_wimp_buffer%!20=ymax%
  2018. +  _wimp_buffer%!24=0:_wimp_buffer%!28=0
  2019. 5  _wimp_buffer%!32=xsize%:_wimp_buffer%!36=ysize%
  2020.  "Wimp_DragBox",,_wimp_buffer%
  2021. _transfer_type%=type%
  2022. _transfer_file$=file$
  2023. _transfer_size%=size%
  2024. _transfer_dragging%=
  2025. icon_gettext(W%,I%)
  2026. F!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%:
  2027.  &400CE,,_wimp_buffer%
  2028.  (_wimp_buffer%!24 
  2029.  1)=0 
  2030.  (_wimp_buffer%!24 
  2031.  256) 
  2032. os_getstring(_wimp_buffer%!28)
  2033. wimp_messagebox(C%,T$,M$)
  2034.  B%,R%,F%:B%=_wimp_buffer%:F%=17:
  2035.  F%=19
  2036. $!B%=0:$(B%+4)=M$:?(B%+4+
  2037. (M$))=0
  2038.  &400DF,B%,F%,T$ 
  2039. win_findwin(H%)
  2040.  E%,A%,F%,P%
  2041. %DE%=
  2042. size_of(_win_list%):F%=-1:
  2043.  A%=0 
  2044.  E%-1 
  2045.  4:P%=_win_list%!A%
  2046.  P%<>0 
  2047.  !(P%-8)=H% 
  2048.  F%=P%
  2049. win_redrawwin(W%)
  2050.  x1%,y1%,x2%,y2%
  2051. !_wimp_buffer%=W%!-8
  2052.  "Wimp_GetWindowState",,_wimp_buffer%
  2053. x1%=_wimp_buffer%!20
  2054. y2%=_wimp_buffer%!24
  2055. /0x2%=x1%+(_wimp_buffer%!12)-(_wimp_buffer%!4)
  2056. 00y1%=y2%+(_wimp_buffer%!8)-(_wimp_buffer%!16)
  2057.  "Wimp_ForceRedraw",W%!-8,x1%,y1%,x2%,y2%
  2058. menu_popup(M%,X%,Y%)
  2059. 5P_wimp_oldmenu%=M%:_wimp_oldmx%=X%:_wimp_oldmy%=Y%:M%=!(_wimp_menu%+4*(M%+1))
  2060.  &400D4,,M%,X%,Y%
  2061. icon_getselect(W%,I%)
  2062. :F!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%:
  2063.  &400CE,,_wimp_buffer%
  2064.  (_wimp_buffer%!24 
  2065.  &200000) 
  2066. win_setextent(W%,x%,y%,X%,Y%)
  2067.  B%,O%,w%,h%:B%=_wimp_buffer%
  2068. !B%=W%!-8
  2069.  "Wimp_GetWindowState",,B%
  2070. :w%=X%-x%:h%=Y%-y%
  2071.  w% < B%!20+(B%!12-B%!4) 
  2072.   O%=
  2073.   B%!20 = w%-(B%!12-B%!4)
  2074.  B%!20<0 
  2075.  (B%!12-B%!4)>w% 
  2076.     B%!20 = 0
  2077.     B%!12 = B%!4 + w%
  2078.  h% < (B%!16-B%!8)-B%!24 
  2079.   O%=
  2080.   B%!24 = (B%!16-B%!8)-h%
  2081.  B%!24>0 
  2082.  (B%!16-B%!8)>h% 
  2083.     B%!24 = 0
  2084.     B%!8 = B%!16 - h%
  2085.  "Wimp_OpenWindow",,B%
  2086. T8!B%=x%:B%!4=y%:B%!8=X%:B%!12=Y%:
  2087.  &400D7,!(W%-8),B%
  2088. icon_select(W%,I%)
  2089. X-!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%
  2090. Y4_wimp_buffer%!8=&200000:_wimp_buffer%!12=&200000
  2091.  &400CD,,_wimp_buffer%
  2092. icon_deselect(W%,I%)
  2093. ^-!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%
  2094. _._wimp_buffer%!8=0:_wimp_buffer%!12=&200000
  2095.  &400CD,,_wimp_buffer%
  2096. realloc(
  2097.  P%,N%)
  2098.  A%,B%,C%
  2099.  P%=0 
  2100. malloc(N%):
  2101. f8C%=!(P%-4):B%=N%:N%=12+(N% 
  2102.  16)*16:
  2103.  N%<B% 
  2104.  N%+=16
  2105.  N%<=C% 
  2106.  (C%-N%)>15 
  2107.  !(P%-4)=N%:
  2108. add_free(P%+N%,C%-N%)
  2109. jL  A%=P%+C%+4:
  2110.  _mem_code%+8:B%=!_memrv%:A%=0:
  2111.  B%<>0 
  2112.  B%=!B%:A%=!(B%-4)
  2113.  B%<>0 
  2114.  C%+A%+4>=N% 
  2115. l%    !!_memrv%=!B%:!(P%-4)=C%+A%+4
  2116.     A%=C%:C%=
  2117. malloc(N%)
  2118.  C%<>0 
  2119. p/      B%=P%:
  2120.  _mem_code%+12:
  2121. free(P%):P%=C%
  2122. q        
  2123. r6      
  2124.  _mem_error% 
  2125.  11,"Can't allocate memory"
  2126. s        
  2127. font_setangle(theta)
  2128. __font_angle=theta
  2129. _font_settransform
  2130. coord_wintoreal(W%,
  2131.  B%:B%=_wimp_buffer%
  2132. !B%=!(W%-8):
  2133.  &400CB,,B%
  2134. &X%=X%-B%!20+B%!4:Y%=B%!16-B%!24+Y%
  2135. font_setcolour(fore%,back%)
  2136.  "ColourTrans_SetFontColours",0,back%,fore%,14
  2137. font_plottext(text$,font%,x%,y%)
  2138. x% = x% * 400
  2139. y% = y% * 400
  2140.  "Font_Paint",font%,text$,%01111000000,x%,y%,,__font_transform%,
  2141.  text$
  2142. coord_realtowin(W%,
  2143.  B%:B%=_wimp_buffer%
  2144. !B%=!(W%-8):
  2145.  &400CB,,B%
  2146. &X%=X%+B%!20-B%!4:Y%=Y%+B%!24-B%!16
  2147. add_free(A%,L%)
  2148. :L%=(L% 
  2149.  16)*16:
  2150.  L%>0 
  2151.  !A%=L%-4:A%+=4:
  2152.  _mem_code%+4
  2153. size_of(P%)
  2154. =!(P%-4)
  2155. wimp_addmessages(M%)
  2156.  "Wimp_AddMessages",M%
  2157. os_putstring(P%,S$)
  2158. $P%=S$:?(P%+
  2159. (S$))=0
  2160. os_getstring(P%)
  2161.  S$:S$="":
  2162.  ?P%>31 S$+=
  2163. (?P%):P%+=1:
  2164. menu_remove
  2165.  "Wimp_CreateMenu",,-1
  2166. event_iconbarmenu(X%)
  2167.  Y%,M%:
  2168. wimp_error(1,
  2169. $+" at line "+
  2170. wimp_mainmenu:Y%=96+
  2171. menu_menuheight(M%):X%-=16+(
  2172. menu_width(M%) 
  2173. menu_popup(M%,X%,Y%)
  2174. menu_keepopen
  2175.  _wimp_oldmenu%=-1 
  2176. *M%=!(_wimp_menu%+4*(_wimp_oldmenu%+1))
  2177.  &400CF,,_wimp_buffer%
  2178.  (_wimp_buffer%!8 
  2179.  &400D4,,M%,_wimp_oldmx%,_wimp_oldmy%
  2180. event_message(B%)
  2181.  B%!16 
  2182.  0 : 
  2183. wimp_quit
  2184. tolower(S$)
  2185.  R$,A%,C%,L%:L%=
  2186. (S$):R$="":
  2187.  L%=0 
  2188. A%=1 
  2189.  L%:C%=
  2190. S$,A%,1)):
  2191.  C%>64 
  2192.  C%<91 
  2193.  C%+=32
  2194. (C%):
  2195. free(A%)
  2196.  _mem_code%+4:L%=!_memrv%
  2197.  (L%+!(L%-4))=_mtop% 
  2198.  (4+!(L%-4))>=_mpsize% 
  2199. _less_memory
  2200. temp_copy(N$)
  2201.  F%,P%,S%,A%,T%,D%,L%,N%,B%,C%,I%
  2202. 'F%=0:P%=_temp_list%:N$=
  2203. tolower(N$)
  2204.  $(P%+16)=N$ 
  2205.  F%=P%
  2206.   P%=!P%
  2207.  F%=0 
  2208. wimp_error(1,0,"Can't locate template "+N$)
  2209. size_of(F%!8):P%=
  2210. malloc(S%+20)+16:T%=F%!8:!(P%-16)=&76C0000:!(P%-12)=0
  2211.  A%=0 
  2212.  S%-1 
  2213.  4:!(P%+A%+4)=T%!A%:
  2214. size_of(F%!12)
  2215. malloc(S%):!(P%-4)=D%:!(P%-8)=0:!P%=P%+4
  2216.  (T%!56)
  2217.  256 
  2218.  L%=T%!80:
  2219.  A%=0 
  2220.  L%-1 
  2221.  4:D%!A%=!(T%!72+A%):
  2222. :!(P%+72+4)=D%:D%+=L%
  2223. N%=T%!84:
  2224.  N%=0 
  2225.  B%=0 
  2226.  N%-1:I%=!(T%+104+32*B%)
  2227.  (I% 
  2228.  256)<>0 
  2229.  ((I% 
  2230.  1)<>0 
  2231.  (I% 
  2232.  2)<>0) 
  2233. )  C%=108+32*B%:L%=!(T%+C%+8):
  2234.  L%>0 
  2235. -    
  2236.  A%=0 
  2237.  L%-1 
  2238.  4:D%!A%=!(A%+T%!C%):
  2239. G    !(P%+C%+4)=D%:!(P%+C%+12)=L%:D%+=L%:!(P%+C%+8)=-1:A%=!(T%+C%+4)
  2240. b    
  2241.  (I% 
  2242.  1)<>0 
  2243.  A%>1 
  2244.  !(P%+C%+8)=D%:T$=
  2245. os_getstring(A%):
  2246. os_putstring(D%,T$):D%+=1+
  2247. win_createwin(D%)
  2248.  W%,A%,E%,F%
  2249.  !(D%-8)<>0 
  2250. wimp_error(1,0,"Trying to create a window that's already there")
  2251.  &400C1,,!D% 
  2252.  W%:!(D%-8)=W%
  2253. size_of(_win_list%):F%=-1:
  2254.  A%=0 
  2255.  E%-1 
  2256.  _win_list%!A%=0 
  2257.  F%=A%
  2258.  F%=-1 
  2259. realloc(_win_list%,E%+16):F%=E%:
  2260.  A%=E% 
  2261.  E%+15 
  2262.  4:_win_list%!A%=0:
  2263. _win_list%!F%=D%
  2264. menu_menuheight(N%)
  2265.  A%,H%,P%:N%+=1:P%=!(_wimp_menu%+4*N%):H%=0:A%=-1:
  2266. :A%+=1
  2267. *H%+=44:
  2268.  (!(P%+A%*24+28) 
  2269.  H%+=22
  2270.  (!(P%+A%*24+28) 
  2271.  128)
  2272. menu_width(N%)
  2273.  P%:P%=!(_wimp_menu%+(N%+1)*4)
  2274. =P%!16
  2275.